<template>
  <work-template v-loading="loading" v-model="ruleForm"
                 @submitOn="submitOn"
                 :flowId="flowId"
                 @closeSelectedTag="closeSelectedTag" :butShow="true">
    <div slot="form" class="container-div">
      <!--车辆信息  订单信息-->
      <vehicleMessage v-model="ruleForm" state="readonly"/>

      <!--处置结果-->
      <!--      <disposalResult v-model="ruleForm" state="write" ref="refDisposalResult"/>-->

    </div>
  </work-template>
</template>

<script>
import {getDetails, submit} from '@/api/vehicleDisposal/purchaseHandle.js'

export default {
  name: 'PurchaseHandleDisposal',
  components: {
    vehicleMessage: () => import('../../components/purchaseHandle/vehicleMessage.vue'),
    disposalResult: () => import('../../components/purchaseHandle/disposalResult.vue'),
  },
  computed: {
    flowId() {
      return this.$route.query?.flowId
    }
  },
  watch: {},
  data() {
    return {
      ruleForm:{}
    };
  },
  created() {
    this.handleDetail()
  },
  mounted() {
  },
  methods: {
    async handleDetail() {
      this.loading = true
      try {
        if (!this.$route.query.id) return
        const res = await getDetails(this.$route.query.id)
        this.ruleForm = res.data
        this.ruleForm.leasePurchaseTransferId = this.$route.query.id
      } catch (e) {
        console.error(e)
      } finally {
        this.loading = false
      }
    },

    closeSelectedTag(view) {
      this.$tab.closePage(view).then(({visitedViews}) => {
        this.$router.push({
          path: "/VehicleDisposal/RentPurchaseTransfer/PurchaseHandleList",
        });
      });
    },

    submitOn() {
      const loading = this.$loading({
        lock: true,
        text: "保存中",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)",
      });
      submit(this.ruleForm).then(res => {
        if (res.code === 200) {
          loading.close()
          this.closeSelectedTag()
        }
      }).finally(() => {
        loading.close()
      })
    }
  },
};
</script>

<style lang="scss" scoped>
@import "@/styles/cwgd/container.scss";
</style>


